<template>
    <el-dialog
        v-if="this.activeData.__config__.setValueForm == '1'"
        :visible="true"
        width="50%"
        :fullscreen="fullScreen"
        :append-to-body="true"
        :close-on-click-modal="false"
        :close-on-press-escape="false"
        :before-close="handleClose">
        <span slot="title" class="el-dialog__title">
            值来源设置
            <i class="el-icon-full-screen iconClass" v-if="!fullScreen" @click="()=>{fullScreen = true}"></i>
            <i class="el-icon-aim iconClass" v-else @click="()=>{fullScreen = false}"></i>
        </span>
        <div class="dialogBody">
            <div class="divClass">
                <span>值来源:</span>
                <el-select filterable placeholder="请选择" v-model="valueName" :style="{width: '81%'}" value-key="__config__">
                    <el-option
                        v-for="(item, index) in formOptions"
                        :key="index"
                        :label="item.__config__.label"
                        :value="item"
                    />
                </el-select>
            </div>
            <div class="divClass">
                <span>字段映射:</span>
                <span class="des">子表单数据来源字段名须子表单字段名一致，数据方可自动填充</span>
            </div>
            <div class="dialog-footer divClass">
                <el-button size="small" @click="handleClose">取消</el-button>
                <el-button size="small" type="primary" @click="confirm">确定</el-button>
            </div>
        </div>
    </el-dialog>
</template>
<script>
export default {
    name: 'SettingLinkDataDialog',
    data () {
        return {
            fullScreen: false,
            formOptions: [],
            valueName: "",
        }
    },
    props: ['activeData', 'fields','drawingList'],
    created () {
        const cascaderList = this.drawingList.filter(item => { return item.__config__.tagIcon === "cascader" })
        const selectList =  this.drawingList.filter(item => { return item.__config__.tagIcon === "select" })
        this.formOptions = [...cascaderList,...selectList]
        this.valueName = this.activeData.__config__.valueConfig
    },
    methods: {
        confirm () {
            if (!this.valueName) {
                return this.$message.warning('请选择值来源')
            }
            this.$emit('closeValueDialog', this.valueName)
        },
        // 关闭弹框
        handleClose () {
            this.$emit('closeValueDialog', false)
        },
    }
}
</script>
<style lang="less" scoped>
/deep/.el-dialog__title{
    width: 100%;
}
.valueCss{
    display:inline-block;
    width:63px;
    text-align:center
}
.divClass{
    margin: 15px 0px;
    display: flex;
    align-items: center;
    span:nth-child(1) {
        width: 70px;
    }
    .des{
        color: #1890FF;
        font-size: 13px;
    }
}

.dialog-footer{
    float: right;
}
.tipClass{
    background-color: oldlace;
    color: orange;
    height: 28px;
    line-height: 28px;
    padding-left: 10px;
    font-size: 12px;
}
/deep/.el-button--medium {
    padding: 0px 20px;
    margin-top: 85px;
}
.iconClass{
    float:right;
    margin-right:25px;
    line-height: 1.5;
}
/deep/.el-dialog__body{
    height: 200px;
    padding: 0px 20px;
}
</style>